#include <iostream>

using namespace std;

const int N = 1e5 + 10;
int f[N];
int a[N];

int main()
{
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 2; i <= n; i++) f[i] = min(f[i - 1] + a[i - 1], f[i - 2] + a[i - 2]);
	cout << f[n] << endl;
	return 0;
} 
